<template>
  <div>
    <basic-container>
      <avue-tabs :option="option"
                 v-model="form"
                 @change="handleChange"
                 @submit="handleSubmit"></avue-tabs>
    </basic-container>
  </div>
</template>

<script>
import option from '@/const/info/form'
import {update} from "@/api/admin/user";
export default {
  data () {
    return {
      type: 'info',
      option: option,
      form: {},
    }
  },
  created () {
    this.handleWitch();
  },
  methods: {
    handleSubmit () {
        let dto=this.form;
        update(dto).then(res => {
            this.$message({
                showClose: true,
                message: "操作成功:" + res.data.message,
                type: "success"
            });
        }).catch(err => {
            this.$message.error("网络异常:" + err)
        });
      // this.$message({
      //   message: this.form,
      //   type: "success"
      // });
    },
    handleWitch () {

      if (this.type === 'info') {

        this.form = this.$store.state.user.userInfo

        //     {
        //   username: 'smallwei',
        //   name: 'smallwei',
        //   phone: '1888888888888',
        //   detail: '这是一个个性签名'
        // }

      } else if (this.type === 'password') {
        this.form = {
          oldpassword: null,
          newpassword: null,
          newpasswords: null
        }
      }
    },
    handleChange (item) {
      this.type = item.prop;
      this.handleWitch();
    },
  }
};
</script>

<style>
</style>
